package com.xiaobai.netease_news.adapters;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.xiaobai.netease_news.utils.ImageUniversalLoaderConfiguration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Android Studio
 * Project: Netease_News
 * Author: Jack
 * Email: jackfangqi1314@gmail.com/jackfangqi@163.com
 * Date: 2015/6/26
 */
public class HeaderPagerAdapter extends PagerAdapter {

    private Context context;
    private List<ImageView> imgList;
    private ViewPager mViewPager;

    public HeaderPagerAdapter(Context context, List<ImageView> imgList, ViewPager mViewPager) {
        this.context = context;
        this.imgList = imgList;
        this.mViewPager = mViewPager;
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        int newPos = position % imgList.size();
        mViewPager.removeView(imgList.get(newPos));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        int newPos = position % imgList.size();
        mViewPager.addView(imgList.get(newPos));

        return imgList.get(newPos);
    }

}
